package microcredit.gui.base;

import java.awt.Cursor;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;

import javax.swing.JFrame;

public class BaseFrame extends JFrame implements IBaseWindow {

	private static final long serialVersionUID = 1L;

//	private final RightClick rightClick = new RightClick(getContentPane());
	
	public BaseFrame() throws HeadlessException {
		super();
		initialize();
	}

	public BaseFrame(GraphicsConfiguration gc) {
		super(gc);
		initialize();
	}

	public BaseFrame(String title, GraphicsConfiguration gc) {
		super(title, gc);
		initialize();
	}

	public BaseFrame(String title) throws HeadlessException {
		super(title);
		initialize();
	}
	
	private void initialize() {
//		setGlassPane(rightClick);
//		rightClick.setVisible(true);
//		rightClick.setEnabled(false);
	}

	@Override
	public void setLoadingState(boolean loading) {
		setLoadingStateImpl(this, loading);
	}

	static void setLoadingStateImpl(JFrame w, boolean loading) {
		Cursor c;
		if (loading) {
			c = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
		} else {
			c = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
		}
		w.setCursor(c);
		w.getRootPane().setCursor(c);
		w.getContentPane().setCursor(c);
		w.getLayeredPane().setCursor(c);
		w.getGlassPane().setCursor(c);
	}

}
